<?php
header('content-type:text/html;charset=utf-8');
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$sex=$_REQUEST['sex'];
$tel=$_REQUEST['tel'];
$address=$_REQUEST['address'];
$age=$_REQUEST['age'];

include('./connt.php');

$select="select*from users where username='$username'";
$res=$conn->query($select);
if($res->num_rows>0){
    echo'<script>alert("用户名已存在");</script>';
    echo'<script>location.href="../注册页面.html";</script>';
    die();
}

$work="insert into users (username,password,sex,tel,address,age) value('$username','$password',$sex,'$tel','$address',$age)";
$work=$conn->query($work);
echo $work;
if($work){
    echo'<script>alert("注册成功");</script>';
    echo'<script>location.href="../登录页面.html";</script>';
}
?>